/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gr.uop.cst.context.adaptation;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

/**
 *
 * @author jbourlakos
 */
public class ContextRuleOutputStream extends ObjectOutputStream {
    public static final String FILE_PREFIX = "aspectj_";
    public static final String FILE_SUFFIX = ".adaptation.object";
    
    private String filename;
    private OutputStream outputStream;
    
    public ContextRuleOutputStream(File f) throws IOException {
        this(new FileOutputStream(f));
        this.filename = f.getAbsolutePath();
    }
    
    public ContextRuleOutputStream(String filename) throws IOException {
        this(new File(filename));
    }
    
    public ContextRuleOutputStream(OutputStream os) throws IOException {
        super(os);
        this.outputStream = os;
    }
    
    public ContextRuleOutputStream() throws IOException {
        this(File.createTempFile(FILE_PREFIX, FILE_SUFFIX));
    }
    
    public void writeContextRule(ContextRule cr) throws IOException {
        this.writeObject(cr);
    }
    
    public String getFilename() {
        return this.filename;
    }
    
}
